<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<%@ page import="com.josiejune.documentdispatch.models.Operator" %>
<%@ page import="com.josiejune.documentdispatch.models.DAO" %>
<%@ page import="com.josiejune.documentdispatch.models.DDMessage" %>
<%@ page import="com.josiejune.documentdispatch.handlers.OperatorHandler" %>
<%@ page import="java.net.URLEncoder" %>
<%@ page import="java.util.Map" %>
<%@ page import="java.util.Iterator" %>
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> 
<title>Route Message</title> 
	
  <link rel="stylesheet" href="styles/stencil/screen.css" type="text/css" media="screen" charset="utf-8" /> 
  <link rel="stylesheet" href="styles/stencil/print.css" type="text/css" media="print" charset="utf-8" /> 
  <link rel="stylesheet" href="styles/stencil/custom.css" type="text/css" media="screen" title="no title" charset="utf-8" /> 
  <link href="styles/stencil/lib/plugins/forms.css" rel="stylesheet" type="text/css" /> 
  <link href="styles/stencil/lib/plugins/buttons.css" rel="stylesheet" type="text/css" /> 
  <link href="styles/stencil/lib/plugins/grid.css" rel="stylesheet" type="text/css" /> 
  <link href="styles/stencil/lib/typography.css" rel="stylesheet" type="text/css" /> 
</head> 
<body id="index"> 
 
<div id="page" class="xgrid xfluid"> 
	
	<div id="header" class="x12">		
		<div class="xpad"> 
			<h1>Route Message</h1>		
		</div> 
	</div> 
	
<%@ include file="headermenu.jsp" %>
<div class="x5" />
<% 
	DAO dao = new DAO();
	DDMessage message = dao.getMessage(Long.valueOf(request.getParameter("msgId")));
	if (message.getStatus().equals("COMPLETED")) {
		%>
		<b>This message has been completed.  It cannot be re-routed.</b>
	<%} else { %>
	
<form action="/routepo?opId=<%= URLEncoder.encode(request.getParameter("opId"), "UTF-8") %>&msgId=<%=URLEncoder.encode(request.getParameter("msgId"), "UTF-8")%>" method=post class="stn-form label-inline simple"> 

<div class="field">
	<h4><label for="toOpId">Route To:</label> </h4>
	<select name="toOpId" size="1">
<% 
	Map<Long, String> map = OperatorHandler.getAllOpIDsAndNames();
	Iterator<Long> keys = map.keySet().iterator();
	while (keys.hasNext()) {
		Long key = keys.next();
		%>
	 	<option value=<%= key %>><%= map.get(key) %></option>
<% } %>

	</select>
	
</div>

<input type="radio" name="managed" value="YES" checked>Managed</input><br/>
<input type="radio" name="managed" value="NO">Unmanaged</input><br/>

    <input type=submit value="Route" />
    </form>
    
    <br/>
    <br/>
    <form name="unmgd" action="/routepounmgd?opId=<%= URLEncoder.encode(request.getParameter("opId"), "UTF-8") %>&msgId=<%=URLEncoder.encode(request.getParameter("msgId"), "UTF-8")%>" method=post class="stn-form label-inline simple"> 
    	<input type=submit value="Route to Next Available Operator" />
    </form>
    

	<%}   %>

</div>

</body> 
</html>